﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Collections.ObjectModel;

using System.Windows.Input;

namespace HA.ModFlow.Application
{
   public class RGToolViewModel:HViewModel
    {

       public RGToolViewModel()
       {
           

           this._currentTool = APPTOOLMODE.GRID3D;


           this._scatter2dTool = new Scatter2dTVM();

           this._grid3dTool = new Grid3dTVM();

           this._mapDataTool = new MapDataTVM();



       }


       Scatter2dTVM _scatter2dTool;

       public Scatter2dTVM Scatter2dTool
       {
           get { return _scatter2dTool; }
           set { _scatter2dTool = value; }
       }

       Grid3dTVM _grid3dTool;

       public Grid3dTVM Grid3dTool
       {
           get { return _grid3dTool; }
           set { _grid3dTool = value; }
       }

       MapDataTVM _mapDataTool;

       public MapDataTVM MapDataTool
       {
           get { return _mapDataTool; }
           set { _mapDataTool = value; }
       }





        APPTOOLMODE _currentTool;

        public APPTOOLMODE CurrentTool
        {
            get { return _currentTool; }
            set {

                if (this._currentTool != value)
                {

                    _currentTool = value;


                    this.OnAppModeChanged();

                }

             
             
           
               
            }
        }


        protected void OnAppModeChanged()

        {

            switch (this._currentTool)
            {
                case APPTOOLMODE.GRID3D:
                    this._grid3dTool.Tool = GRID3DTOOLS.SELECTCELL;

                    GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(HAGISV2.MAPMODE.GRIDCELL);


                    break;
                case APPTOOLMODE.SCATTER2D:
                    this._scatter2dTool.Tool = SCATTER2DTOOLS.SELECT;

                    GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(HAGISV2.MAPMODE.SCATTER2DSELECT);

                   
                    break;
                case APPTOOLMODE.MAPDATA:

                    this._mapDataTool.Tool = MAPDATATOOL.SELECT;

                    GisModule.DefaultModule.GisManager.InteractiveSystem.SetMapMode(HAGISV2.MAPMODE.ALLSELECT);


                    break;
                default:
                    break;
            }


            this.OnPropertyChanged("IsScatterMode");
            this.OnPropertyChanged("IsGrid3dMode");
            this.OnPropertyChanged("IsMapDataMode");





        }


      



        private ICommand _setGrid3dModeCommand;

        public ICommand SetGrid3dModeCommand
        {
            get
            {

                if (this._setGrid3dModeCommand == null)
                {
                    this._setGrid3dModeCommand = new RelayCommand(m => this.CurrentTool = APPTOOLMODE.GRID3D);

                }

                return _setGrid3dModeCommand;
            }

        }

     


        ICommand _setScatter2dModeCommand;

        public ICommand SetScatter2dModeCommand
        {
            get {


                if (this._setScatter2dModeCommand == null)
                {
                    this._setScatter2dModeCommand = new RelayCommand(m => this.CurrentTool = APPTOOLMODE.SCATTER2D);

                }
                
                return _setScatter2dModeCommand; 
            
            }
           
        }


        ICommand _setMapDataModeCommand;

        public ICommand SetMapDataModeCommand
        {
            get {

                if (this._setMapDataModeCommand == null)
                {
                    this._setMapDataModeCommand = new RelayCommand(m => this.CurrentTool = APPTOOLMODE.MAPDATA);

                }

                return _setMapDataModeCommand;
            
            
            }
          
        }


        public bool IsScatterMode
        {

            get {

                if (this._currentTool == APPTOOLMODE.SCATTER2D)
                {
                    return true;

                }
                else
                {
                    return false;
                }
            }

            set
            {


                //this.CurrentTool = APPTOOLMODE.SCATTER2D;
            }


        }


        public bool IsGrid3dMode
        {

            get
            {

                if (this._currentTool == APPTOOLMODE.GRID3D)
                {
                    return true;

                }
                else
                {
                    return false;
                }
            }

            set
            {
                //this.CurrentTool = APPTOOLMODE.GRID3D;
            }


        }


        public bool IsMapDataMode
        {

            get
            {

                if (this._currentTool == APPTOOLMODE.MAPDATA)
                {
                    return true;

                }
                else
                {
                    return false;
                }
            }


            set
            {

                //this.CurrentTool = APPTOOLMODE.MAPDATA;
            }

        }






    }
}
